AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
 
include( 'shared.lua' )

function GM:PlayerSpawn( ply )
    self.BaseClass:PlayerSpawn( ply )   
 
    ply:SetGravity  ( 1 )  
    ply:SetMaxHealth( 100, true )  
 
    ply:SetWalkSpeed( 190 )  
    ply:SetRunSpeed ( 235 ) 
	
	RunConsoleCommand("gr_team");
end

GR_TEAM = { 1, 2 }
GR_ADMIN = { 4 }

function GM:PlayerInitialSpawn( ply ) 
	ply:SetTeam( table.Random( GR_TEAM ) )
	if ply:IsUserGroup() == "superadmin" then
		ply:SetTeam( 4 )
		ply:ChatPrint( "You have been placed on the DEV team for being an admin." )
	end 
end
 
function GM:PlayerLoadout( ply ) 
    if ply:Team() == 1 then 
        ply:StripWeapons()
		ply:Give("weapon_physcannon")
		ply:Give("weapon_toolgun")
		ply:Give("gmod_camera")
		ply:Give( "weapon_physgun" )
		ply:Give( "gmod_tool" )
	elseif ply:Team() == 2 then
		ply:StripWeapons()
		ply:Give("weapon_physcannon")
		ply:Give("weapon_toolgun")
		ply:Give("gmod_camera")
		ply:Give( "weapon_physgun" )
	ply:Give( "gmod_tool" )
	elseif ply:Team() == 4 then
		ply:StripWeapons()
		ply:Give("weapon_physcannon")
		ply:Give("weapon_crowbar")
		ply:Give("weapon_toolgun")
		ply:Give("gmod_camera")
		ply:Give( "weapon_physgun" )
		ply:Give( "gmod_tool" )
	end
end 
 
 concommand.Add( "gr_team",function( ply,cmd,args,str )
	if ply:Team() == 1 then 
		ply:ChatPrint( "Your team is: Red Team")
	elseif ply:Team() == 2 then
		ply:ChatPrint( "Your team is: Blue Team")
	elseif ply:Team() == 4 then
		ply:ChatPrint( "Your team is: Dev (ADMIN)" )
	end
end )

/*concommand.Add( "gr_getcar",function( ply,cmd,args,str )
	if ply:Team() == 1 then
		ents.Create("bugatti")
	elseif ply:Team() == 2 then
		ents.Create("69camaro")
	end

end )
*/
concommand.Add( "gr_changeteam",function( ply,cmd,args,str )
	if ply:Team() == 1 then
		ply:SetTeam( 2 )
		ply:ChatPrint( "You have changed to Blue Team!" )
	elseif ply:Team() == 2 then
		ply:SetTeam( 1 )
		ply:ChatPrint( "You have changed to Red Team!" )
	elseif ply:Team() == 4 then
		ply:SetTeam( table.Random( GR_TEAM ) )
		ply:ChatPrint ( "You have changed to " ply:Team() )
	end
	end
end )

concommand.Add( "gr_adminteam",function( ply,cmd,args,str )
	if ply:Team() == 1 or 2 then
		ply:SetTeam( 4 )
		if ply:Team( 4 ) then
			print("You have been set to Team Dev!")
		elseif not ply:Team( 4 ) then 
			print( "You have not been set to Team Dev" ) 
		end
	end
		
end )

concommand.Add( "gr_score",function( ply, com, args )
	umsg.Start( "gr_score", ply )
end ) 